﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SGRapidForm.Permission.Service.Interface;
using SGRapidForm.Permission.Entity;
using SGRapidForm.Permission.Component;
using System.Collections.Specialized;
using SGRapidForm.Common;
using System.Data;
using Microsoft.Practices.Unity;

namespace SGRapidForm.Permission.Service
{
    public partial class PermissionService : IPermissionService
    {
        [Dependency]
        public UserDeptComponent UserDeptComponent
        { get; set; }
       
        /// <summary>
        /// 为用户分配部门
        /// </summary>
        /// <param name="userDept">用户部门明细</param>
        /// <returns></returns>
        public bool UserDept_Add(UserDept userDept)
        {
            return this.UserDeptComponent.UserDept_Add(userDept);
        }

        /// <summary>
        /// 为用户分配部门
        /// </summary>
        /// <param name="userDept">用户部门集合</param>
        /// <returns></returns>
        public bool UserDept_BulkAdd(List<UserDept> userDept)
        {
            return this.UserDeptComponent.UserDept_BulkAdd(userDept);
        }

        /// <summary>
        /// 为用户移除部门
        /// </summary>
        /// <param name="userKeyid">用户Keyid</param>
        /// <param name="deptKeyid">部门Keyid</param>
        /// <returns></returns>
        public bool UserDept_Delete(string userKeyid, string deptKeyid)
        {
            return this.UserDeptComponent.UserDept_Delete(userKeyid, deptKeyid);
        }

        /// <summary>
        /// 为用户移除部门
        /// </summary>
        /// <param name="userKeyid">用户Keyid</param>
        /// <param name="deptKeyids">部门Keyid集合</param>
        /// <returns></returns>
        public bool UserDept_BulkDelete(string userKeyid, string[] deptKeyids)
        {
            return this.UserDeptComponent.UserDept_BulkDelete(userKeyid, deptKeyids);
        }

        /// <summary>
        /// 用户是否拥有此部门
        /// </summary>
        /// <param name="userKeyid"></param>
        /// <param name="deptKeyid"></param>
        /// <returns></returns>
        public bool UserDept_Exists(string userKeyid, string deptKeyid)
        {
            return this.UserDeptComponent.UserDept_Exists(userKeyid, deptKeyid);
        }

        /// <summary>
        /// 查询已经分配给指定用户的部门
        /// </summary>
        /// <param name="userKeyid"></param>
        /// <returns></returns>
        public List<Dept> UserDept_GetDeptByUserKeyid(string userKeyid)
        {
            return this.UserDeptComponent.UserDept_GetDeptByUserKeyid(userKeyid);
        }

        /// <summary>
        /// 查询未分配给指定用户的部门
        /// </summary>
        /// <param name="userKeyid"></param>
        /// <returns></returns>
        public List<Dept> UserDept_GetUnmappedDeptByUserKeyid(string userKeyid, string filterConditions)
        {
            return this.UserDeptComponent.UserDept_GetUnmappedDeptByUserKeyid(userKeyid, filterConditions);
        }
        
    }
}
